Poodle.onDOMReady(function()
{
	var xhr = new PoodleXHR();
	xhr.uname = $("register-username");
	xhr.email = $("register-email");
	if (xhr.uname) {
		xhr.uname.label = xhr.uname.parent().$A("label");
//		uname.bind("blur", function(){xhr.post(Poodle.PATH+"xml-http.php", onComplete, "validate_username="+encodeURIComponent(uname.value))});
		xhr.uname.select();
		xhr.uname.bind("blur", function(){xhr.post(xhr.uname.form.action, onCompleteUname, "validate_username="+encodeURIComponent(xhr.uname.value))});
	}
	if (xhr.email) {
		xhr.email.label = xhr.email.parent().$A("label");
		xhr.email.bind("blur", function(){xhr.post(xhr.email.form.action, onCompleteEmail, "validate_email="+encodeURIComponent(xhr.email.value))});
	}
	function onCompleteUname(pxhr)
	{
		var ok = 200 == pxhr.xhr.status;
		xhr.uname.removeClass(ok ? "xhr_error" : "xhr_ok");
		xhr.uname.addClass(ok ? "xhr_ok" : "xhr_error");
		xhr.uname.nextElementSibling.className = ok ? "xhr_ok" : "xhr_error";
		xhr.uname.label.className = ok ? "xhr_ok" : "xhr_error";
		xhr.uname.label.html("<br/>"+pxhr.xhr.responseText);
	};
	function onCompleteEmail(pxhr)
	{
		var ok = 200 == pxhr.xhr.status;
		xhr.email.removeClass(ok ? "xhr_error" : "xhr_ok");
		xhr.email.addClass(ok ? "xhr_ok" : "xhr_error");
		xhr.email.nextElementSibling.className = ok ? "xhr_ok" : "xhr_error";
		xhr.email.label.className = ok ? "xhr_ok" : "xhr_error";
		xhr.email.label.html(pxhr.xhr.responseText);
	};
});
